import java.util.Random;
import java.util.Scanner;
public class homework2 {
    public static void main(String[] args){
        Random random = new Random();
        Scanner input = new Scanner(System.in);
        int randNum = random.nextInt(100);
        for(int i=1;i<=3;i++) {

            System.out.println("请猜密码");
            int a = input.nextInt();
            if (i == 3 && a!=randNum) {
                System.out.println("您已经猜了三次,很遗憾。没有猜中!");
                break;
            }
            if (a == randNum) {
                System.out.println("猜对了，密码是:" + a);
                break;
            } else {
                System.out.println("猜错了，请再猜一次！");
            }
        }
    }
}

